package com.example.meterialproject.activitys

import android.os.Bundle
import com.example.meterialproject.base.BaseActivity
import com.example.meterialproject.databinding.ActivityMaterialRadioButtonBinding
import com.example.meterialproject.exts.showSnack
import com.google.android.material.radiobutton.MaterialRadioButton

/**
 *
 * @ClassName: RadioButtonActivity
 * @Author: android 超级兵
 * @CreateDate: 1/20/22$ 2:13 PM$
 * TODO materialRadioButton
 *      switchMaterial
 *      MaterialCheckBox
 *      SwitchMaterial
 */
class RadioButtonActivity : BaseActivity<ActivityMaterialRadioButtonBinding>() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // 单选
        binding.radioGroup.setOnCheckedChangeListener { group, checkedId ->
            group.showSnack(group.findViewById<MaterialRadioButton>(checkedId).text)
        }

        binding.materialCheckoutBox.setOnCheckedChangeListener { buttonView, isChecked ->
            buttonView.showSnack(isChecked)
            buttonView.text = if (isChecked) "红色选中" else "绿色未选中"
        }

        // 自定义materialCheckBox
        binding.materialCheckoutBox2.setOnCheckedChangeListener { buttonView, isChecked ->
            buttonView.showSnack(isChecked)
        }

        // 这是一串文字
        binding.materialSwitch.setOnCheckedChangeListener { buttonView, isChecked ->
            buttonView.showSnack(isChecked)
        }

    }
}